// https://leetcode.cn/problems/longest-palindrome/
// Created by ade on 2022/8/5.
//
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

class Solution {
public:
    int longestPalindrome(string s) {
        int len = s.size();
        if (len == 1) return 1;
        int num = 0;
        sort(s.begin(), s.end());
        int i = 0;
        for (int i = 1; i < len; i++) {
            if (s[i - 1] == s[i]) {
                i++;
                num += 2;
            }
        }
        if (num < len) return num + 1;
        return num;
    }
};

int main() {
    string s = "abccccdd";
    Solution so;
    cout << so.longestPalindrome(s) << endl;
    return 0;
}